package com.example.demo.service;


import com.example.demo.dao.SysUserMapper;
import com.example.demo.domains.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 处理用户的业务逻辑.
 * User: lyh
 * Date: 2017/8/9
 * Time: 16:16
 */
@Service
public class SysUserService {

    @Autowired
    private SysUserMapper sysUserMapper;

    /**
     * 获取所有用户信息
     * */
    public List<SysUser> getAll(){
        return sysUserMapper.selectAll();
    }
    /**
     * 插入用户
     *
     * */
    public int saveUser(SysUser sysUser){
        return sysUserMapper.insert(sysUser);
    }

    /**
     * 根据主键获取数据
     *
     * */
    public SysUser getSysUserByPrimaryKey(Long id){
        return sysUserMapper.selectByPrimaryKey(id);
    }

    /**
     * 根据用户名获取数据
     *
     * */
    public SysUser getOneSysUserByUserName(String username){
        SysUser sysUser = new SysUser();
        sysUser.setUsername(username);
        return sysUserMapper.selectOne(sysUser);
    }


}
